<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib prefix="sys" uri="/WEB-INF/tld/sys.tld" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>账户列表</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="sqPanel" style="margin-bottom: 5px;">
        <div class="sqPanel_head" style="height:35px;">
            <table class="table_full">
                <tr>
                    <td><span >收款账户</span></td>
                </tr>
            </table>
        </div>
        <a class="l-button" style="width:100px;float:left; margin-left:6px;" onclick="bind()">选择</a>
<!--         <a class="l-button" style="width:100px;float:left; margin-left:6px;" onclick="toAddPage()">新增</a>
 -->
        <div class="sqPanel_body">
            <div id="ligergrid1" class="sq-grid"></div>
        </div>

    </div>
</div>



<script type="text/javascript">
    var grid = null, form = null;
    var repayId = '${repayId}';
    $(function () {
        initGrid();
        grid.setHeight(300);
    });
    function bind(){
        var row = grid.getSelectedRow();
        var rows = grid.getSelectedRows();
        if(!row || rows.length>1){
            alert("请选择一个银行卡");
        }
         
        var bankId = row.id;
        //
        var url = '<%=path%>/finpayschfee/finance/bindBankAcc.do';
        $.get(url,{repayId:repayId,bankAccId:bankId},function(res){
            // TODO 刷新父页面
            if(res){
                res = JSON.parse(res);
                if(res.code==1){
	                UIUtils.alertSuccess(res.info);
	                parent.grid.reload();
					frameElement.dialog.close();
                }else{
	                UIUtils.alertError(res.info);
                }
            }
        });
    }
    function initGrid(){
        var url = '<%=path%>/capital/finance/loan/apply/bankAcc/initList.do';
        grid = $("#ligergrid1").ligerGrid({
            url:url,
            method: 'get',
            columns: [
                {display: '收款单位', name: 'rcptUnt', minWidth: 130, align: 'left', enabledSort: false},
                {display: '收款账户', name: 'accNo', width: 130, align: 'right', enabledSort: false},
                {display: '开户银行', name: 'bkNm', width: 140, align: 'right', enabledSort: false}
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            checkbox: true,
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            allowUnSelectRow: true,
            alternatingRow: false
        });
    }
    function callback(){
        initGrid();
    }
    function toAddPage(){
        parent.Add_navTab('tab_apply_bankAcc_Add','新增账号','<%=path%>/capital/finance/loan/apply/bankAcc/toAddPage.do',callback);
        <%--parent.parent.mainApp.f_addTab('tab_apply_bankAcc_Add','新增账号','<%=path%>/capital/finance/loan/apply/bankAcc/toAddPage.do');--%>
    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }
</script>

</body>
</html>
